package com.emep.changzhi.analyse.service.datamonitor.hour;

import com.datastax.driver.core.PagingState;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.SimpleStatement;
import com.datastax.driver.core.Statement;
import com.emep.changzhi.analyse.entity.datamonitor.hour.DataHourUnorganizedIndustry;
import com.emep.changzhi.analyse.repository.datamonitor.hour.DataHourUnorganizedRepository;
import com.emep.changzhi.analyse.utils.MapUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author yangj
 * @version V1.0
 * @Description: 工业无组织排放_小时数据表业务层
 * @date 2018/2/27  16:16
 */
@Slf4j
@Service
public class DataHourUnorganizedService {

    @Autowired
    private DataHourUnorganizedRepository dataHourUnorganizedRepository;

    /**
     *
     * 新增
     *
     * @param payload
     * @return
     * @throws Exception
     */
    public DataHourUnorganizedIndustry save(Map<String, Object> payload) {
        DataHourUnorganizedIndustry dataHourUnorganizedIndustry = null;
        try {
            DataHourUnorganizedIndustry dataHourUnorganizedIndustry1 = (DataHourUnorganizedIndustry) MapUtils.convertMap(DataHourUnorganizedIndustry.class,payload);
            dataHourUnorganizedIndustry = dataHourUnorganizedRepository.save(dataHourUnorganizedIndustry1);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return dataHourUnorganizedIndustry;
    }
    /**
     * @author xy
     * @Description: 首页
     * @date 2018/3/8 10:11
     * @version V1.0
     */
    public List<DataHourUnorganizedIndustry> findDataHourUnorganizedIndustryByHome(Integer pageSize){
        List<DataHourUnorganizedIndustry> dataHourUnorganizedIndustrys = null;
        try {
            dataHourUnorganizedIndustrys = dataHourUnorganizedRepository.dataHourUnorganizedHome(pageSize);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return dataHourUnorganizedIndustrys;

    }
    /**
     * @author xy
     * @Description: 翻页查询
     * @date 2018/3/8 10:18
     * @version V1.0
     */

    public List<DataHourUnorganizedIndustry> findDataHourUnorganizedIndustryByFlip(String id,Integer pageSize) {
        List<DataHourUnorganizedIndustry> dataHourUnorganizedIndustrys = null;
        try {
            dataHourUnorganizedIndustrys = dataHourUnorganizedRepository.dataHourUnorganizedFlip(id,pageSize);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return dataHourUnorganizedIndustrys;
    }


}
